import pygame
from constants import Constants

class UIComponents:
    """创建和管理UI组件的类"""
    def __init__(self):
        # 主界面按钮
        self.button_start = pygame.Rect(
            (Constants.WIDTH - Constants.BUTTON_WIDTH) // 2,
            Constants.HEIGHT // 2 - Constants.BUTTON_HEIGHT * 1.5,
            Constants.BUTTON_WIDTH, Constants.BUTTON_HEIGHT
        )
        self.button_history = pygame.Rect(
            (Constants.WIDTH - Constants.BUTTON_WIDTH) // 2,
            Constants.HEIGHT // 2,
            Constants.BUTTON_WIDTH, Constants.BUTTON_HEIGHT
        )
        self.button_exit = pygame.Rect(
            (Constants.WIDTH - Constants.BUTTON_WIDTH) // 2,
            Constants.HEIGHT // 2 + Constants.BUTTON_HEIGHT * 1.5,
            Constants.BUTTON_WIDTH, Constants.BUTTON_HEIGHT
        )

        # 游戏界面按钮
        self.button_random = pygame.Rect(Constants.WIDTH - 200, Constants.HEIGHT - 100,
                                        Constants.BUTTON_WIDTH, Constants.BUTTON_HEIGHT)
        self.button_custom = pygame.Rect(Constants.WIDTH - 400, Constants.HEIGHT - 100,
                                        Constants.BUTTON_WIDTH, Constants.BUTTON_HEIGHT)
        self.button_play = pygame.Rect(Constants.WIDTH - 600, Constants.HEIGHT - 100,
                                       Constants.BUTTON_WIDTH, Constants.BUTTON_HEIGHT)